package com.share.tool.devops.controller;

import com.share.common.common.Result;
import com.share.tool.devops.service.JenkinsService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class JenkinsController {

    @Autowired
    private JenkinsService jenkinsService;

    @ApiOperation("构建任务")
    @RequestMapping("/createJob")
    public Result<String> createJob(String projectName, Map<String, String> paramMap) {
        return Result.success(jenkinsService.createJob(projectName, paramMap));
    }

    @ApiOperation("构建任务")
    @RequestMapping("/buildJob")
    public Result buildJob(String projectName) {
        return Result.success(jenkinsService.buildJob(projectName));
    }

    @ApiOperation("构建日志")
    @RequestMapping("/buildLog")
    public Result buildLog(String projectName) {
        return Result.success(jenkinsService.buildLog(projectName));
    }
}
